<template>
    <div class="e-form">
        <div class="title">{{ formData.projectName }}公开招标</div>
        <div class="tabs">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="招标包件信息"
                    name="package"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要业绩"
                    name="enterprise"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="资质信息" name="quaInfo" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane
                    label="企业主要管理人"
                    name="manager"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="附件信息" name="attach" :disabled="clickTabFlag"></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form
                                ref="ruleForm"
                                :model="formData"
                                label-width="170px"
                                :rules="rules"
                            >
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="统一社会信用代码" prop="unitCode">
                                            <el-input
                                                v-model="formData.unitCode"
                                                placeholder="请先输入统一社会信用代码"
                                                maxlength="18"
                                                @blur="unitCodeBlur(formData.unitCode)"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="投标单位" prop="unitName">
                                            <el-input
                                                v-model="formData.unitName"
                                                :disabled="unitCodeState2"
                                                :maxlength="50"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="法人代表" prop="legalRepresentative">
                                            <el-input
                                                v-model="formData.legalRepresentative"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item
                                            label="注册资本（万元）"
                                            prop="registerCaptial"
                                        >
                                            <el-input
                                                v-model="formData.registerCaptial"
                                                :disabled="unitCodeState"
                                                v-enterJustFloat2
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="联系电话" prop="telephone">
                                            <el-input
                                                v-model="formData.telephone"
                                                :disabled="unitCodeState2"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="传真" prop="fax">
                                            <el-input
                                                v-model="formData.fax"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="邮箱" prop="email">
                                            <el-input
                                                v-model="formData.email"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="是否为境外单位" prop="isAbroad">
                                            <el-switch
                                                :width="60"
                                                v-model="formData.isAbroad"
                                                class="main-el-switch"
                                                active-color="#13ce66"
                                                inactive-color="#D2D2D2"
                                                active-value="1"
                                                inactive-value="0"
                                                active-text="是"
                                                inactive-text="否"
                                                @change="isAbroadUnitChange"
                                            ></el-switch>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="分包商类型" prop="outsourceValue">
                                            <el-checkbox
                                                :indeterminate="isIndeterminate"
                                                v-model="checkAll"
                                                @change="handleCheckAllChange"
                                                :disabled="unitCodeState"
                                            >
                                                全选
                                            </el-checkbox>
                                            <el-checkbox-group
                                                v-model="formData.outsourceValue"
                                                @change="handleCheckedCitiesChange"
                                                :disabled="unitCodeState"
                                            >
                                                <el-checkbox
                                                    v-for="item in typeList"
                                                    :key="item.kvId"
                                                    :label="item.kvKey"
                                                    :value="item.kvId"
                                                ></el-checkbox>
                                            </el-checkbox-group>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row style="align-items: stretch">
                                    <el-col :span="12">
                                        <el-form-item label="地址：" prop="registerAddress">
                                            <SelectAddr
                                                v-model="formData.registerAddress"
                                                lazy
                                                showCountry
                                                style="width: 100%"
                                                :disabled="unitCodeState"
                                            ></SelectAddr>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="纳税类别：" prop="taxpayerType">
                                            <el-radio-group
                                                @change="radioChange($event)"
                                                v-model="formData.taxpayerType"
                                                :disabled="unitCodeState"
                                            >
                                                <el-radio
                                                    v-for="item in payTaxesTypeList"
                                                    :key="item.kvId"
                                                    :disabled="item.disabled"
                                                    :label="item.kvKey"
                                                    :value="item.kvValue"
                                                ></el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row> </el-row>
                                <span v-if="isShow">
                                    <el-row style="align-items: stretch">
                                        <el-col :span="24">
                                            <el-form-item
                                                label="固定工作地址："
                                                prop="fixAddressCode"
                                            >
                                                <SelectAddr
                                                    v-model="formData.fixAddressCode"
                                                    lazy
                                                    showCountry
                                                    style="width: 100%"
                                                    :disabled="unitCodeState"
                                                ></SelectAddr>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item
                                                label="企业基本情况："
                                                prop="enterpriseBase"
                                            >
                                                <el-input
                                                    v-model="formData.enterpriseBase"
                                                    :disabled="unitCodeState"
                                                    type="el-input"
                                                    :maxlength="500"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="企业注册建造师数量："
                                                prop="certifiedConstructorNum"
                                            >
                                                <el-input
                                                    v-model.number="
                                                        formData.certifiedConstructorNum
                                                    "
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="中级及以上职称人员数量："
                                                prop="middlePosition"
                                            >
                                                <el-input
                                                    v-model.number="formData.middlePosition"
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="持有岗位证书的施工现场管理人员数量："
                                                prop="certificateScene"
                                            >
                                                <el-input
                                                    v-model.number="formData.certificateScene"
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="经考核或培训合格的中级工以上技术工人数量："
                                                prop="middleTechnology"
                                            >
                                                <el-input
                                                    v-model.number="formData.middleTechnology"
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="持有安全C证人员数量："
                                                prop="safetyNum"
                                            >
                                                <el-input
                                                    v-model.number="formData.safetyNum"
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item
                                                label="正常缴纳社保人数："
                                                prop="socialNum"
                                            >
                                                <el-input
                                                    v-model.number="formData.socialNum"
                                                    type="number"
                                                    :disabled="unitCodeState"
                                                ></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </span>
                            </el-form>
                        </div>
                    </div>

                    <div id="packageCon" class="con e-table">
                        <div class="tabs-title" id="package">招标包件信息</div>
                        <el-table
                            :data="packageTableData"
                            border
                            style="width: 100%"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('packageTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column type="selection" width="55"></el-table-column>
                            <el-table-column
                                width="200"
                                prop="itemNo"
                                label="包件号"
                            ></el-table-column>
                            <el-table-column
                                width="200"
                                prop="name"
                                label="包件名称"
                            ></el-table-column>
                            <el-table-column
                                width="150"
                                prop="startEndStake"
                                label="起止桩号"
                            ></el-table-column>
                            <el-table-column
                                min-width="150"
                                prop="projectOverview"
                                label="工程概况"
                            ></el-table-column>
                            <el-table-column
                                min-width="150"
                                prop="priceLimit"
                                label="招标最高限价（元）"
                            ></el-table-column>
                        </el-table>
                    </div>

                    <div id="enterpriseCon" class="con e-table">
                        <div class="tabs-title" id="enterprise">
                            <span style="color: red" v-if="unitCodeState2 === true">*</span>
                            企业主要业绩
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="enterpriseAdd(enterpriseTableData)"
                                v-if="!unitCodeState"
                            >
                                新增
                            </el-button>
                            <el-button class="btn-delete" @click="delete1" v-if="!unitCodeState">
                                删除
                            </el-button>
                        </div>
                        <div
                            style="margin-bottom: 20px"
                            class="errorMsg"
                            v-if="errorMsg2.length > 0"
                        >
                            <span
                                style="display: block"
                                v-for="(item, index) in errorMsg2"
                                :key="index"
                            >
                                {{ item }}
                            </span>
                        </div>
                        <el-table
                            :data="enterpriseTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @select="selectClick1"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('enterpriseTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column
                                width="100"
                                label="操作"
                                type="selection"
                                :disabled="unitCodeState"
                            ></el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractName"
                                label="合同名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractName"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="projectName"
                                label="项目名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.projectName"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractAmount"
                                label="合同金额（元）"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractAmount"
                                        placeholder="请输入内容"
                                        v-enterJustFloat
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="workContent"
                                label="所承担工作内容"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.workContent"
                                        placeholder="请输入内容"
                                        :maxlength="200"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="startTime" label="开工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :disabled="unitCodeState"
                                    ></el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="endTime" label="竣工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.endTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :picker-options="pickerOptions(row)"
                                        style="width: 150px"
                                        :disabled="unitCodeState"
                                    ></el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="personInCharge" label="项目负责人">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.personInCharge"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witness"
                                label="业绩证明人"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witness"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witnessPhone"
                                label="证明人电话"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witnessPhone"
                                        placeholder="请输入内容"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="200"
                                prop="safetyEvaluation"
                                label="质量安全信誉评价意见"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.safetyEvaluation"
                                        placeholder="请输入内容"
                                        :maxlength="200"
                                        :disabled="unitCodeState"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" prop="proveFile" label="证明附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button
                                                size="mini"
                                                v-if="!unitCodeState"
                                                type="primary"
                                            >
                                                上传
                                            </el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a
                                                    :href="row.filePath"
                                                    target="_blank"
                                                    v-if="row.filePath"
                                                >
                                                    {{ row.fileName }}
                                                </a>
                                                <a v-else>{{ row.fileName }}</a>
                                            </div>
                                            <!-- 正好没返path，没附件id反正也删不掉 -->
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.filePath"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="quaInfoCon" class="con e-table">
                        <div class="tabs-title" id="quaInfo">
                            <span style="color: red" v-if="unitCodeState2 === true">*</span>
                            资质信息
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="quaInfoAdd(quaInfoTableData)"
                                v-if="!unitCodeState"
                            >
                                新增
                            </el-button>
                            <el-button class="btn-delete" @click="delete2" v-if="!unitCodeState">
                                删除
                            </el-button>
                        </div>
                        <div
                            style="margin-bottom: 20px"
                            class="errorMsg"
                            v-if="errorMsg.length > 0"
                        >
                            <span
                                style="display: block"
                                v-for="(item, index) in errorMsg"
                                :key="index"
                            >
                                {{ item }}
                            </span>
                        </div>
                        <el-table
                            :data="quaInfoTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @select="selectClick2"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('quaInfoTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column
                                width="100"
                                label="操作"
                                type="selection"
                            ></el-table-column>
                            <el-table-column width="150" prop="certificateType" label="证书类型">
                                <template slot-scope="{ row }">
                                    <el-select
                                        v-model="row.certificateType"
                                        placeholder="请选择"
                                        :disabled="unitCodeState"
                                        @change="certificateTypeChange($event, row)"
                                    >
                                        <el-option
                                            v-for="item in options2.certificateType"
                                            :key="item"
                                            :label="item"
                                            :value="item"
                                        ></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="certificateNo" label="证书及编号">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.certificateNo"
                                        placeholder="请输入内容"
                                        :disabled="
                                            row.certificateType === '营业执照' || unitCodeState
                                        "
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="certificateGrade"
                                label="主营范围/证书等级"
                            >
                                <template slot-scope="{ row, $index }">
                                    <span>
                                        <el-input
                                            v-if="
                                                row.certificateType === '营业执照' ||
                                                row.certificateType === '资质证书'
                                            "
                                            readonly
                                            :disabled="unitCodeState"
                                            v-model="row.certificateGrade"
                                            placeholder="请选择"
                                        >
                                            <i
                                                slot="suffix"
                                                class="el-icon-document-copy"
                                                @click="onSelect(row, $index)"
                                                :disabled="unitCodeState"
                                                style="cursor: pointer"
                                                v-if="
                                                    unitCodeState2 === false &&
                                                    unitCodeState === false
                                                "
                                            ></i>
                                        </el-input>
                                    </span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="validateStart" label="有效开始日期">
                                <template slot-scope="{ row, $index }">
                                    <el-date-picker
                                        v-model="row.validateStart"
                                        type="date"
                                        placeholder="选择日期"
                                        :disabled="unitCodeState"
                                        value-format="yyyy-MM-dd"
                                        @change="choiceStart(row, $event, $index)"
                                    ></el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" prop="validateEnd" label="有效结束日期">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.validateEnd"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :picker-options="pickerOptions(row)"
                                        style="width: 150px"
                                        :disabled="
                                            row.certificateType === '安全生产许可证' ||
                                            unitCodeState
                                        "
                                    ></el-date-picker>
                                    <el-button
                                        class="btn-blue"
                                        style="margin-left: 10px"
                                        size="mini"
                                        @click="forever(row, 'validateEnd')"
                                        v-if="row.certificateType !== '安全生产许可证'"
                                    >
                                        永久
                                    </el-button>
                                    <span
                                        v-else
                                        style="margin-left: 10px; padding: 7px 30px"
                                        size="mini"
                                    ></span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="fileName"
                                label="文件名"
                            ></el-table-column>
                            <el-table-column width="150" prop="fileSize" label="大小">
                                <template slot-scope="{ row }" v-if="row.fileSize">
                                    {{ bytesToSize(row.fileSize) }}
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="200"
                                prop="upTime"
                                label="上传时间"
                            ></el-table-column>
                            <el-table-column width="250" label="附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            v-if="row.recordId"
                                            ref="enterpriseUpload"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button
                                                size="mini"
                                                type="primary"
                                                v-if="!unitCodeState"
                                            >
                                                上传
                                            </el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a :href="row.filePath" target="_blank">
                                                    {{ row.fileName }}
                                                </a>
                                            </div>
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.fileName && !unitCodeState"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="managerCon" class="con e-table">
                        <div class="tabs-title" id="manager">
                            <span style="color: red" v-if="unitCodeState2 === true">*</span>
                            企业主要管理人
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="managerAdd(managerTableData)"
                                v-if="!unitCodeState"
                            >
                                新增
                            </el-button>
                            <el-button class="btn-delete" @click="delete3" v-if="!unitCodeState">
                                删除
                            </el-button>
                        </div>
                        <div
                            style="margin-bottom: 20px"
                            class="errorMsg"
                            v-if="errorMsg1.length > 0"
                        >
                            <span
                                style="display: block"
                                v-for="(item, index) in errorMsg1"
                                :key="index"
                            >
                                {{ item }}
                            </span>
                        </div>
                        <el-table
                            :data="managerTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @select="selectClick3"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('managerTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column
                                width="100"
                                label="操作"
                                type="selection"
                            ></el-table-column>
                            <el-table-column width="150" prop="typeName" label="人员类别">
                                <template slot-scope="{ row }">
                                    <el-select
                                        v-model="row.typeName"
                                        :disabled="unitCodeState"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="(item, index) in options2.applyPersonnelsType"
                                            :key="index"
                                            :label="item"
                                            :disabled="unitCodeState"
                                            :value="item"
                                        ></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="name" label="姓名">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.name"
                                        :disabled="unitCodeState"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="idCardNo" label="身份证号码">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.idCardNo"
                                        :disabled="unitCodeState"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="certNo" label="证书及编号">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.certNo"
                                        :disabled="unitCodeState"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="phone" label="联系电话">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.phone"
                                        :disabled="unitCodeState"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="startTime"
                                label="身份证有效开始时间"
                                l
                            >
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        :disabled="unitCodeState"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                    ></el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="250"
                                prop="endTime"
                                label="身份证有效结束时间"
                                l
                            >
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.endTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :disabled="unitCodeState"
                                        :picker-options="pickerOptions(row)"
                                        style="width: 150px"
                                    ></el-date-picker>
                                    <el-button
                                        class="btn-blue"
                                        style="margin-left: 10px"
                                        size="mini"
                                        @click="forever(row, 'endTime')"
                                    >
                                        永久
                                    </el-button>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="fileName" label="身份证附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :disabled="unitCodeState"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button
                                                size="mini"
                                                type="primary"
                                                v-if="!unitCodeState"
                                            >
                                                上传
                                            </el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a :href="row.filePath" target="_blank">
                                                    {{ row.fileName }}
                                                </a>
                                            </div>
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.fileName && !unitCodeState"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="attachCon" class="con e-table">
                        <div class="tabs-title" id="attach">附件信息</div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="attachAdd(attachTableData)"
                                v-if="!unitCodeState"
                            >
                                新增
                            </el-button>
                            <el-button class="btn-delete" @click="delete4" v-if="!unitCodeState">
                                删除
                            </el-button>
                        </div>
                        <div
                            style="margin-bottom: 20px"
                            class="errorMsg"
                            v-if="errorMsg3.length > 0"
                        >
                            <span
                                style="display: block"
                                v-for="(item, index) in errorMsg3"
                                :key="index"
                            >
                                {{ item }}
                            </span>
                        </div>
                        <el-table
                            :data="attachTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            highlight-current-row
                            @select="selectClick4"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('attachTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column
                                width="100"
                                label="操作"
                                type="selection"
                            ></el-table-column>
                            <el-table-column width="150" prop="type" label="附件类型">
                                <template slot-scope="{ row }">
                                    <el-select
                                        v-model="row.type"
                                        :disabled="unitCodeState"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="(item, index) in options2.fileType"
                                            :disabled="unitCodeState"
                                            :key="index"
                                            :label="item"
                                            :value="item"
                                        ></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column
                                min-width="250"
                                prop="fileName"
                                align="left"
                                label="文件名"
                            ></el-table-column>
                            <el-table-column width="150" prop="size" label="大小"></el-table-column>
                            <el-table-column
                                width="150"
                                prop="upTime"
                                label="上传时间"
                            ></el-table-column>
                            <el-table-column min-width="250" label="操作">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button
                                                size="mini"
                                                type="primary"
                                                v-if="!unitCodeState"
                                            >
                                                上传
                                            </el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a :href="row.filePath" target="_blank">
                                                    {{ row.fileName }}
                                                </a>
                                            </div>
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.fileName && !unitCodeState"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
                <div style="font-weight: bold">
                    承诺：我代表公司承诺，上述信息正确、合法有效、若招标人（发起人）在招标过程中或中标后发现上述信息存在虚假、我们承诺承袒由此造成的所有责任（包括但不限于无条件故弃中标）。
                </div>
            </el-tabs>
        </div>

        <div class="buttons">
            <el-button type="primary" class="btn-blue" @click="submit"> 提交 </el-button>
            <el-button @click="reset">重置</el-button>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialogVisible"
            width="50%"
            style="padding: 50px"
        >
            <span>
                <el-tree
                    :props="props"
                    :load="loadNode"
                    lazy
                    show-checkbox
                    style="margin-top: 20px"
                    @check-change="treeCheckChange"
                    :key="treeKey"
                ></el-tree>
            </span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="diaLogSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
import applyRequest from '@/api/tender/apply.js'
import tenderRequest from '@/api/tender/tender.js'
import commonRequest from '@/api/tender/common.js'
import call from '@/api/OutsourcingartyAdmin/getAllType.js'
import ossRequest from '@/api/oss/oss.js'
import { mapState } from 'vuex'
import SelectAddr from '@/components/common/addrComp'
import { ip } from '@/utils/request'
import { uidBuilder } from '@/api/base/uid.js'
import { bytesToSize, getUuid } from '@/utils/common'
import openBiddingRequest from '@/api/tender/openBidding.js'
import { creditCodeVerification, isName, isPostCode, isPhone, isEmail, isFax } from '@/utils/rules'

export default {
    data () {
        return {
            unitCodeState: true, // 信用代码是否通过状态，true全禁止，false可编辑
            unitCodeState2: true, // 信用代码通过，代理人、固定电话、联系电话、企业主要业绩可以编辑
            errorMsg: [], //资质信息错误提示
            errorMsg1: [], //主要管理人信息错误提示
            errorMsg2: [], //主要业绩信息错误提示
            errorMsg3: [], //附件信息错误提示
            deleteData1: [], //资质信息删除数据
            deleteData2: [], //主要管理人删除数据
            deleteData3: [], //主要业绩删除数据
            deleteData4: [], //附件信息删除数据
            // 基础信息
            formData: {
                address: '',
                addressCode: '',
                addressDetail: '',
                applyId: '',
                billId: '',
                email: '',
                enterpriseBase: '',
                fax: '',
                fixAddress: '',
                fixAddressCode: '',
                fixAddressDetail: '',
                fixedTelephone: '',
                isAbroad: '0',
                legalRepresentative: '',
                projectName: '',
                proxyUser: '',
                qualificationLevel: '',
                registerCaptial: null,
                taxpayerType: '',
                telephone: '',
                unitCode: '',
                unitId: '',
                unitName: '',
                outsourceType: [], //分包商类型【id】
                outsourceValue: [], //分包商类型【名字】
                newData: true //判断是否是当前页面新增数据
            },
            // 包件列表
            packageTableData: [],
            // 包件名字
            // packageName: '',
            // 资质信息
            quaInfoTableData: [],
            // 历史业绩
            enterpriseTableData: [],
            // 企业主要管理人
            managerTableData: [],
            attachTableData: [],
            upData: {
                bucketName: 'tender',
                relationId: ''
            },
            ip: ip + '/oss/uploader',
            selection: {
                packageTableData: []
            },
            tenderData: {}, //基础招标信息
            // enterpriseFormData: [],
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            tableData: [],
            value: '',
            // el-input: '',
            test: '',
            selectData: [],
            selectTableColumnAttr: [
                {
                    label: '单据编号',
                    prop: 'billNo'
                },
                {
                    label: '拟招标项目名称',
                    prop: 'tenderName'
                },
                {
                    label: '单据日期',
                    prop: 'gmtCreate'
                },
                {
                    label: '单据机构名称',
                    prop: 'orgName'
                }
            ],
            selectTableColumnWidth: {
                leftWidth: '150',
                rightWidth: '100'
            },
            selectDataPagination: {},
            fileList4: [],
            isIndeterminate: true,
            checkAll: false, //是否全选
            typeList: [],
            payTaxesTypeList: [],
            isShow: true, //是否显示企业详情填写
            pickerOptions: row => {
                return {
                    disabledDate (time) {
                        return time.getTime() < new Date(row.startTime).getTime() + 86400000
                    }
                }
            },
            rules: {
                // 信用代码
                unitCode: [
                    {
                        required: true,
                        validator: creditCodeVerification,
                        trigger: 'blur'
                    }
                ],
                //分包商名称
                outsourceValue: [
                    {
                        required: true,
                        message: '请选择分包商类型',
                        trigger: 'blur'
                    }
                ],
                //纳税类别
                taxpayerType: [
                    {
                        required: true,
                        message: '请选择纳税类别',
                        trigger: 'change'
                    }
                ],
                //地址
                registerAddress: [
                    {
                        required: true,
                        message: '请选择地址',
                        trigger: 'change'
                    }
                ],
                //注册资本
                registerCaptial: [
                    {
                        required: true,
                        message: '请输入注册资本',
                        trigger: 'change'
                    }
                ],
                // 法人代表
                legalRepresentative: [
                    {
                        required: true,
                        validator: isName,
                        trigger: 'blur'
                    }
                ],
                //邮编
                postCode: [
                    {
                        validator: isPostCode,
                        trigger: 'blur'
                    }
                ],
                //传真
                fax: [
                    {
                        validator: isFax,
                        trigger: 'blur'
                    }
                ],
                unitName: {
                    required: true,
                    type: 'string',
                    message: '请输入投标单位'
                },
                telephone: [
                    {
                        required: true,
                        validator: isPhone,
                        trigger: 'blur'
                    }
                ],
                // 邮箱
                email: [{ required: true, validator: isEmail, trigger: 'blur' }],
                // 固定地址
                fixAddressCode: [
                    {
                        required: true,
                        message: '请选择固定地址',
                        trigger: 'change'
                    }
                ],
                //企业基本情况
                enterpriseBase: [
                    {
                        required: true,
                        message: '请输入企业基本情况',
                        trigger: 'blur'
                    }
                ],
                //企业注册建造师数量
                certifiedConstructorNum: [
                    {
                        required: true,
                        message: '请输入企业注册建造师数量',
                        trigger: 'blur'
                    }
                ],
                //中级及以上职称人员数量
                middlePosition: [
                    {
                        required: true,
                        message: '请输入中级及以上职称人员数量',
                        trigger: 'blur'
                    }
                ],
                //持有岗位证书的施工现场管理人员数量
                certificateScene: [
                    {
                        required: true,
                        message: '请输入持有岗位证书的施工现场管理人员数量',
                        trigger: 'blur'
                    }
                ],
                //持有安全C证人员数量
                safetyNum: [
                    {
                        required: true,
                        message: '请输入持有安全C证人员数量',
                        trigger: 'blur'
                    }
                ],
                //正常缴纳社保人数
                socialNum: [
                    {
                        required: true,
                        message: '请输入正常缴纳社保人数',
                        trigger: 'blur'
                    }
                ],
                //经考核或培训合格的中级工以上技术工人数量
                middleTechnology: [
                    {
                        required: true,
                        message: '请输入经考核或培训合格的中级工以上技术工人数量',
                        trigger: 'blur'
                    }
                ]
            },
            messageError: {
                enterpriseTableData: '' // 企业业绩信息
            },
            dialogVisible: false,
            dialogTitle: '',
            props: {
                label: 'kvValue',
                // children: 'zones',
                isLeaf: 'isLeaf'
            },
            // treeCheckSet: new Set(),
            treeCheckSet: [],
            // treeCheckStr: '', //保存主营范围选择的值
            treeCheckStr: [],
            row: null, //资质信息 主营范围/资质等级 回调弹窗保存的当前row
            index: null,
            treeKey: 0
        }
    },
    watch: {
        'formData.outsourceValue' (val) {
            console.log()
            val[val.findIndex(item => item === '施工合作')] = '施工分包'
        }
    },
    computed: {
        ...mapState({
            options2: state => state.biddingApplication.openDictionaries,
            options: state => state.biddingApplication.dictionaries
        }),
        // ...mapState({
        //     options: state => state.biddingApplication.openDictionaries
        // }),
        ...mapState(['userInfo']),
        tenderId () {
            // return this.formData.tenderApplyId
            return this.$route.query.tenderId || this.$route.query.billid //假数据
        },
        billId () {
            return this.$route.query.billId || this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        SelectAddr
    },
    created () {
        // 915101125671801455
        // 外包方类型、纳税人类别
        this.getTypeData()
        ;(async () => {
            await this.getTenderData() // 获取招标基础信息
            this.getPackage() // 获取包件信息
        })()
    },
    mounted () {
        // 保存所有tabName
        const arr = ['baseInfo', 'package', 'enterprise', 'quaInfo', 'manager', 'attach']
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight(arr)
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }
            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const itemTop = document.getElementById(item)?.offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item)?.offsetTop
                return itemTop
            })
        })
    },
    beforeDestroy () {
        this.$notify.closeAll()
        // this.options2.taxpayerType[1].disabled = true
    },
    methods: {
        diaLogSubmit () {
            this.dialogVisible = false
            // this.row.certificateGrade = [...this.treeCheckSet].join(',')
            this.row.certificateGrade = this.treeCheckStr[this.index]
            // this.treeCheckStr = ''
        },
        treeCheckChange (data, isCheck) {
            if (!this.treeCheckSet[this.index]) {
                this.treeCheckSet[this.index] = new Set()
            }
            if (!this.treeCheckStr[this.index]) {
                this.treeCheckStr[this.index] = ''
            }
            if (isCheck) {
                this.treeCheckSet[this.index].add(data.kvValue)
            } else {
                this.treeCheckSet[this.index].delete(data.kvValue)
            }
            this.treeCheckStr[this.index] = [...this.treeCheckSet[this.index]].join(',')
            // this.treeCheckSet = new Set()
        },
        async loadNode (node, resolve) {
            if (node.level === 0) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: 0
                })
                return resolve(res)
            }
            if (node.level >= 1) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: node.data.kvId
                })
                return resolve(res)
            }
        },
        onSelect (row, index) {
            // console.log('row', row)
            // console.log('index', index)
            // 需要刷新 主营范围/证书等级 接口
            this.treeKey += 1
            // 弹窗后需要改变，所以保存
            this.row = row
            this.index = index
            this.dialogVisible = true
            this.dialogTitle =
                row.certificateType === '营业执照' ? '请选择主营范围' : '请选择资质等级'
        },
        // 资质信息 证书类型切换
        certificateTypeChange (val, row) {
            // 证书类型，安全许可证，不能选择日期结束时间，根据有效期开始时间加3年
            if (val === '安全生产许可证') {
                row.endTime = new Date(
                    Date.parse(new Date(row.startTime)) + 31536000000 * 3 + 86400000
                )
            }
            // 营业执照时，证书编号为信用代码
            if (val === '营业执照') {
                row.certificateNo = this.formData.unitCode
            }
        },
        // 境外单位选择
        changeIsAbroad (val) {
            // 是境外单位纳税类别可以选择小规模纳税人
            if (val === 1 && this.unitCodeState === false) {
                this.options2.taxpayerType[1].disabled = false
            } else {
                this.options2.taxpayerType[1].disabled = true
            }
        },
        forever (row, name) {
            row[name] = '9999-12-30'
        },
        selectionChange (tabaleName, selection) {
            this.selection[tabaleName] = selection
        },
        // 企业主要管理人新增
        async managerAdd (table) {
            table.push({
                billId: '', //	单据ID
                certNo: '', //证书及编号
                changeState: 0, //前端操作状态
                endTime: '', //身份证有效结束日期
                fileName: '', //身份证附件名称
                filePath: '', //身份证附件路径
                gmtModified: '', //上次修改时间
                idCardNo: '', //身份证号
                name: '', //姓名
                phone: '', //	联系电话
                startTime: '', //身份证有效开始日期
                type: '', //	人员类别[id]
                typeName: '', //	人员类别[name]
                uuid: getUuid(), //本地的uuid区分每条数据
                recordId: await this.uidBuilder({
                    num: 1
                })
            })
        },
        // 附件新增
        async attachAdd (table) {
            table.push({
                billId: '', //	单据ID
                filePath: '', //	文件路径
                name: '', //文件名称
                size: null, //文件大小
                type: '', //类型
                upTime: '', //上传时间
                uuid: getUuid(), //本地的uuid区分每条数据
                recordId: await this.uidBuilder({
                    num: 1
                })
            })
        },
        // 资质信息增加
        async quaInfoAdd (table) {
            table.push({
                billId: '', //单据ID
                certificateGrade: '', //主营范围/证书等级
                certificateNo: '', //证书编号
                certificateType: '', //证书类型
                changeState: 0, //前端操作状态
                fileName: '', //	文件名称
                filePath: '', //文件路径
                fileSize: 0, //文件大小
                gmtCreate: '',
                gmtModified: '',
                upTime: '', //上传时间
                validateEnd: '', //有效期结束日期
                validateStart: '', //有效期开始日期
                uuid: getUuid(), //本地的uuid区分每条数据
                recordId: await this.uidBuilder({
                    num: 1
                })
            })
        },
        // 主要业绩增加
        async enterpriseAdd (table) {
            table.push({
                billId: '', //单据ID
                changeState: 0, //前端操作状态
                contractAmount: 0, //	合同金额
                contractName: '', //合同名称
                endTime: '', //竣工时间
                filePath: '', //证明附件
                gmtCreate: '', //创建时间
                gmtModified: '', //上次修改时间
                personInCharge: '', //项目负责人
                projectName: '', //项目名称
                safetyEvaluation: '', //质量安全信誉评价意见
                startTime: '', //开工时间
                witness: '', //	业绩证明人
                witnessPhone: '', //证明人电话
                workContent: '', //	所承担工程内容
                uuid: getUuid(), //本地的uuid区分每条数据
                recordId: await this.uidBuilder({
                    num: 1
                })
            })
        },

        //获取分包商类型数据
        getTypeData () {
            call.getCredentialTree({ name: '外包方类型', id: '0' }).then(res => {
                let id = ''
                // 获取想要的类型id
                res.map(item => {
                    if (item.kvKey == '分包商') {
                        id = item.kvId
                    }
                })
                call.getCredentialTree({ name: '外包方类型', id: id }).then(res => {
                    this.typeList = res
                })
                call.getCredential('纳税类别').then(res => {
                    this.payTaxesTypeList = res
                })
            })
        },
        // 提交
        async submit () {
            /**
             * 判断该数据是自己页面新增还是从库内查回来，如果newData为false则为库内单位
             * 如果是库内单位，则不验证必填，直接存到后端， 如果是库外单位则需要去验证必填
             */
            if (this.formData.outsourceType instanceof Array) {
                this.formData.outsourceType = this.formData.outsourceType.join(',')
            }
            if (this.formData.outsourceValue instanceof Array) {
                this.formData.outsourceValue = this.formData.outsourceValue.join(',')
            }
            console.log('this.formData1111', this.formData.outsourceValue)
            if (!this.formData.newData) {
                if (
                    this.selection.packageTableData &&
                    this.selection.packageTableData.length != 0
                ) {
                    this.selection.packageTableData.map(item => {
                        item.unitCode = this.formData.unitCode //统一社会信用代码
                        item.packageId = item.billId //包件id
                        item.tenderApplyId = this.formData.tenderApplyId //招标id
                    })
                    this.formData['enrollPackage'] = this.selection.packageTableData //包件
                    this.formData['enterpriseAchievement'] = this.enterpriseTableData //主要业绩
                    this.formData['enrollCertificates'] = this.quaInfoTableData //资质信息
                    this.formData['enrollPerson'] = this.managerTableData //主要管理人
                    this.formData['attachment'] = this.attachTableData //附件信息
                    this.formData.billId = '' //置空billId
                    await tenderRequest
                        .erollCreate(this.formData)
                        .then(() => {
                            this.clientPop('suc', '提交成功')
                        })
                        .catch(() => {
                            this.clientPop('err', '提交失败')
                        })
                } else {
                    this.clientPop('suc', '请选择包件信息')
                }
            } else {
                // 验证错误信息
                this.errorMsg = []
                this.errorMsg1 = []
                this.errorMsg2 = []
                this.errorMsg3 = []
                // 验证通过
                let adopt1 = false
                let adopt2 = false //资质信息是否通过
                let adopt3 = false
                let adopt4 = false
                let adopt5 = false
                // 基础信息验证
                this.$refs.ruleForm.validate(async valid => {
                    if (!valid) {
                        this.onChangeTab({ name: 'baseInfo' })
                        return
                    } else {
                        // 包件信息
                        if (
                            this.selection.packageTableData &&
                            this.selection.packageTableData.length != 0
                        ) {
                            adopt5 = true
                        } else {
                            adopt5 = false
                            this.clientPop('err', '请选择包件信息')
                        }
                        // 企业主要业绩
                        if (this.enterpriseTableData.length > 0) {
                            let isStr2 = false
                            this.enterpriseTableData.forEach((item, index) => {
                                let str1 = `请完善第 ${index + 1} 行的`
                                if (item.contractName === '' || item.contractName === null) {
                                    let str = '合同名称,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.projectName === '' || item.projectName === null) {
                                    let str = '项目名称,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (
                                    item.safetyEvaluation === '' ||
                                    item.safetyEvaluation === null
                                ) {
                                    let str = '质量安全信誉评价意见,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.filePath === '' || item.filePath === null) {
                                    let str = '证明附件,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.contractAmount === '' || item.contractAmount === null) {
                                    let str = '合同金额,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.workContent === '' || item.workContent === null) {
                                    let str = '所承担工程内容,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.startTime === '' || item.startTime === null) {
                                    let str = '开工时间,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.endTime === '' || item.endTime === null) {
                                    let str = '竣工时间,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.personInCharge === '' || item.personInCharge === null) {
                                    let str = '项目负责人,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.witness === '' || item.witness === null) {
                                    let str = '业绩证明人,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.witnessPhone === '' || item.witnessPhone === null) {
                                    let str = '证明人电话,'
                                    isStr2 = true
                                    str1 += str
                                } else {
                                    if (!/^1[3-9]\d{9}$/.test(item.witnessPhone)) {
                                        let str = '证明人电话格式不正确！'
                                        isStr2 = true
                                        str1 += str
                                    }
                                }
                                if (Date.parse(item.startTime) >= Date.parse(item.endTime)) {
                                    let str = '结束时间必须大于开始时间,'
                                    isStr2 = true
                                    str1 += str
                                }
                                if (item.id) {
                                    return (item.changeType = 2)
                                }
                                if (isStr2) {
                                    this.errorMsg2.push(str1)
                                }
                            })
                            if (this.errorMsg2.length > 0) {
                                adopt1 = false
                            } else {
                                adopt1 = true
                            }
                        } else {
                            this.clientPop('err', '请填写企业主要业绩')
                        }
                        // 资质信息
                        if (this.quaInfoTableData.length > 0) {
                            let isStr = false
                            this.quaInfoTableData.forEach((item, index) => {
                                let str1 = `请完善第 ${index + 1} 行的`
                                if (item.certificateType === '' || item.certificateType === null) {
                                    let str = '证书类型,'
                                    isStr = true
                                    str1 += str
                                }
                                if (item.validateStart === '' || item.validateStart === null) {
                                    let str = '开始时间,'
                                    isStr = true
                                    str1 += str
                                }
                                if (item.validateEnd === '' || item.validateEnd === null) {
                                    let str = '结束时间,'
                                    isStr = true
                                    str1 += str
                                }
                                if (item.fileName === '' || item.fileName === null) {
                                    let str = '资质附件,'
                                    isStr = true
                                    str1 += str
                                }
                                if (
                                    item.certificateType == '营业执照' ||
                                    item.certificateType == '资质证书'
                                ) {
                                    if (
                                        item.certificateGrade === '' ||
                                        item.certificateGrade === null
                                    ) {
                                        let str = '主营范围/证书等级,'
                                        isStr = true
                                        str1 += str
                                    }
                                }
                                if (
                                    Date.parse(item.validateStart) >= Date.parse(item.validateEnd)
                                ) {
                                    let str = '结束时间必须大于开始时间,'
                                    isStr = true
                                    str1 += str
                                }
                                if (item.certificateNo === '' || item.certificateNo === null) {
                                    let str = '证书编号,'
                                    isStr = true
                                    str1 += str
                                }
                                if (isStr) {
                                    this.errorMsg.push(str1)
                                }
                            })
                            if (this.errorMsg.length > 0) {
                                adopt2 = false
                            } else {
                                //分包商资质信息新增(修改)
                                let isContain = [] //定义证书类型临时数组
                                // 将证书类型存入临时数组
                                isContain = this.quaInfoTableData.map(item => {
                                    if (item.state != -1) {
                                        return item.certificateType
                                    }
                                })
                                // 判断哪些字段重复
                                var result = [] //不重复字段
                                var result2 = [] //重复字段
                                for (var i = 0; i < isContain.length; i++) {
                                    if (result.indexOf(isContain[i]) == -1) {
                                        result.push(isContain[i])
                                    } else {
                                        if (result2.indexOf(isContain[i]) == -1) {
                                            result2.push(isContain[i])
                                        }
                                    }
                                }
                                // 判断是否重复，如果重复不进行下一步判断
                                if (result2.length < 1) {
                                    // 判断数据是否完整并且符合条件
                                    /**
                                     * 1.分包商类型选择“劳务合作、施工分包”中的1个或2个，且不是境外单位的时候，
                                     * 必须上传营业执照、资质证书和安全生产许可证；
                                     * 2.勾选了境外单位或外包方类型只有其它的时候，则必须上传营业执照
                                     */
                                    let newData = null
                                    if (this.formData.outsourceValue instanceof Array) {
                                        newData = this.formData.outsourceType.join(',')
                                    } else {
                                        newData = this.formData.outsourceType
                                    }
                                    if (newData == '10' || this.formData.isAbroad == 1) {
                                        //判断证书类型是否包含营业执照，不包含则提示
                                        if (isContain.includes('营业执照')) {
                                            adopt2 = true
                                        } else {
                                            this.errorMsg.push('资质信息必须包含:营业执照,请检查')
                                            this.$emit('setError', 'aptitude')
                                            adopt2 = false
                                        }
                                    } else {
                                        // 如果列表数据不足3条则直接提示不符合条件
                                        //判断证书类型是否包含三种类型，不包含则提示
                                        if (
                                            isContain.includes('营业执照') &&
                                            isContain.includes('资质证书') &&
                                            isContain.includes('安全生产许可证')
                                        ) {
                                            // 将值传回父组件
                                            adopt2 = true
                                        } else {
                                            let str = []
                                            if (!isContain.includes('营业执照')) {
                                                str.push('营业执照')
                                            }
                                            if (!isContain.includes('资质证书')) {
                                                str.push('资质证书')
                                            }
                                            if (!isContain.includes('安全生产许可证')) {
                                                str.push('安全生产许可证')
                                            }
                                            this.errorMsg.push(`资质信息必须包含:${str},请检查`)
                                            adopt2 = false
                                            this.$emit('setError', 'aptitude')
                                        }
                                    }
                                } else {
                                    result2.map(item => {
                                        this.errorMsg.push(`${item}'重复'`)
                                    })
                                }
                            }
                        } else {
                            this.clientPop('err', '请选择资质信息')
                        }
                        // 企业主要管理人
                        if (this.managerTableData.length > 0) {
                            let isStr1 = false
                            this.managerTableData.forEach((item, index) => {
                                let str1 = `请上传第 ${index + 1} 行的`
                                if (item.fileName === '' || item.fileName === null) {
                                    let str = '身份证附件,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (item.startTime === '' || item.startTime === null) {
                                    let str = '身份证有效开始日期 ,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (item.endTime === '' || item.endTime === null) {
                                    let str = '身份证有效结束日期,'
                                    isStr1 = true
                                    str1 += str
                                }

                                if (item.name === '' || item.name === null) {
                                    let str = '姓名,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (item.typeName === '' || item.typeName === null) {
                                    let str = '人员类别,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (Date.parse(item.startTime) >= Date.parse(item.endTime)) {
                                    let str = '结束时间必须大于开始时间,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (item.phone === '' || item.phone === null) {
                                    let str = '联系电话,'
                                    isStr1 = true
                                    str1 += str
                                } else {
                                    if (!/^1[3-9]\d{9}$/.test(item.phone)) {
                                        let str = '联系电话格式不正确！'
                                        isStr1 = true
                                        str1 += str
                                    }
                                }
                                if (item.idCardNo === '' || item.idCardNo === null) {
                                    let str = '身份证号码,'
                                    isStr1 = true
                                    str1 += str
                                } else {
                                    if (
                                        !/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(
                                            item.idCardNo
                                        )
                                    ) {
                                        let str = '身份证号码格式不正确！'
                                        isStr1 = true
                                        str1 += str
                                    }
                                }
                                if (item.certNo === '' || item.certNo === null) {
                                    let str = '证书及编号,'
                                    isStr1 = true
                                    str1 += str
                                }
                                if (isStr1) {
                                    this.errorMsg1.push(str1)
                                }
                            })
                            if (this.errorMsg1.length > 0) {
                                adopt3 = false
                            } else {
                                /**
                                 * 1)董事会成员（持股人）默认生成3行，至少填写1行
                                 * 2)法人代表、实际控制人、总经理、总工程师、技术质量负责人、质量负责人、安全负责人和班组长默认生成1行，至少填写1行；
                                 */
                                if (
                                    (this.formData.outsourceType.includes('8') ||
                                        this.formData.outsourceType.includes('9')) &&
                                    this.formData.isAbroad == 0
                                ) {
                                    let isContain = [] //定义人员类型临时数组
                                    // 将人员类型存入临时数组
                                    isContain = this.managerTableData.map(item => {
                                        if (item.state != -1) {
                                            return item.typeName
                                        }
                                    })
                                    // 去重
                                    let isContains = [...new Set(isContain)]
                                    // 检验哪些不包含在该数组
                                    let newData = this.options2.applyPersonnelsType.filter(item => {
                                        if (!isContains.includes(item)) {
                                            return item
                                        }
                                    })
                                    //判断人员类型是否包含9种类型，不包含则提示
                                    if (newData.length < 1) {
                                        adopt3 = true
                                    } else {
                                        adopt3 = false
                                        this.errorMsg1.push(`${newData.splice(',')}` + '未填写')
                                    }
                                } else {
                                    let isContain = [] //定义人员类型临时数组
                                    // 将人员类型存入临时数组
                                    isContain = this.managerTableData.map(item => {
                                        if (item.state != -1) {
                                            return item.typeName
                                        }
                                    })
                                    //判断证书类型是否包含法人代表，不包含则提示
                                    if (isContain.includes('法人代表')) {
                                        adopt3 = true
                                    } else {
                                        adopt3 = false
                                        this.errorMsg1.push('人员类型必须包含:法人代表')
                                    }
                                }
                            }
                        } else {
                            this.clientPop('err', '请填写企业主要管理人')
                        }
                        // 附件信息
                        //针对分包商类型只是“其他”或是境外单位，附件不是必填
                        if (
                            (this.formData.outsourceType.includes('8') ||
                                this.formData.outsourceType.includes('9')) &&
                            this.formData.isAbroad == 0
                        ) {
                            if (this.attachTableData.length > 0) {
                                this.errorMsg3 = []
                                let oldArry = [
                                    '承诺书',
                                    '组织机构图',
                                    '上年度财务报告或企业年报',
                                    '国家企业信用信息截图',
                                    '社保证明'
                                ]
                                /**
                                 * 1当外包方类型选择含有“施工分包”、“劳务合作”中的1个或2个且没有勾选“是否为境外单位”的时候，默认上面9个类型行，其中，承诺书、组织机构图、上年度财务报告或企业年报、国家企业信用信息截图、社保证明5类必须上传附件，其他类不必传
                                 */
                                let isEnclosure = [] //定义人员类型临时数组
                                // 将类型存入临时数组
                                isEnclosure = this.attachTableData.map(item => {
                                    if (item.state != -1) {
                                        return item.type
                                    }
                                })
                                // 去重
                                let isEnclosures = [...new Set(isEnclosure)]
                                // 检验哪些不包含在该数组
                                let newData = []
                                newData = oldArry.filter(item => {
                                    if (!isEnclosures.includes(item)) {
                                        return item
                                    }
                                })
                                //判断人员类型是否包含5种类型，不包含则提示
                                if (newData.length > 0) {
                                    newData.forEach(item => {
                                        adopt4 = false
                                        this.errorMsg3.push('请添加' + `${item.split(',')}`)
                                    })
                                } else {
                                    // 验证通过修改状态
                                    let isStr = false
                                    this.attachTableData.forEach((item, index) => {
                                        let str1 = `请上传第 ${index + 1} 行的`
                                        if (item.type === '' || item.type === null) {
                                            let str = '类型,'
                                            isStr = true
                                            str1 += str
                                        }
                                        if (item.filePath === '' || item.filePath === null) {
                                            let str = '文件,'
                                            isStr = true
                                            str1 += str
                                        }
                                        if (isStr) {
                                            this.errorMsg3.push(str1)
                                        }
                                    })
                                    if (this.errorMsg3.length > 0) {
                                        adopt4 = false
                                        return
                                    } else {
                                        // 将值传回父组件
                                        adopt4 = true
                                    }
                                }
                            } else {
                                console.log('请上传附件信息')
                                this.clientPop('err', '请上传附件信息')
                            }
                        } else {
                            //境外单位无验证，直接将值传回父组件
                            adopt4 = true
                        }
                        // }
                        // 所有必填验证通过了，才能进行提交，
                        if (adopt1 && adopt2 && adopt3 && adopt4 && adopt5) {
                            //提交
                            if (this.formData.outsourceType instanceof Array) {
                                this.formData.outsourceType = this.formData.outsourceType.join()
                            }
                            this.formData['enrollPackage'] = this.selection.packageTableData //包件
                            this.formData['enterpriseAchievement'] = this.enterpriseTableData //主要业绩
                            this.formData['enrollCertificates'] = this.quaInfoTableData //资质信息
                            this.formData['enrollPerson'] = this.managerTableData //主要管理人
                            this.formData['attachment'] = this.attachTableData //附件信息
                            this.formData.billId = '' //置空billId
                            await tenderRequest
                                .erollCreate(this.formData)
                                .then(() => {
                                    this.clientPop('suc', '提交成功')
                                })
                                .catch(() => {
                                    this.clientPop('err', '提交失败')
                                })
                        }
                    }
                })
            }
            if (typeof this.formData.outsourceValue == 'string') {
                this.formData.outsourceValue = this.formData.outsourceValue.split(',')
            }
            console.log('this.formData', this.formData)
        },

        bytesToSize (byte) {
            return bytesToSize(byte)
        },
        async delFile (row) {
            await ossRequest.deleterByRelationId({ relationId: row.recordId }).then(() => {
                row.fileName = ''
                row.filePath = ''
                row.fileSize = ''
            })
        },
        // 上传成功后
        handleAvatarSuccess (response, file, fileList, row) {
            const res = response.data[0]
            row.fileName = res.originalObjectName
            // row.name = res.originalObjectName
            row.filePath = res.objectPath
            row.fileSize = res.objectSize
            row.upTime = res.gmtCreate
            row.size = res.objectSize
            this.$refs.enterpriseUpload.clearFiles() //上传成功之后清除历史记录
        },
        async uidBuilder (params, type = 'str') {
            let temp = []
            await uidBuilder(params).then(res => {
                temp = type === 'str' ? res[0] : res
            })
            return temp
        },
        // 上传前
        async beforeAvatarUpload (file) {
            const isLt2M = file.size / 1024 / 1024 < 20
            if (!isLt2M) {
                this.clientPop('err', '上传文件大小不能超过 20MB！')
            }
            return isLt2M
        },
        getObjectByRelationId () {
            if (!this.relationId) return
            return ossRequest.getObjectByRelationId({ relationId: this.relationId }).then(res => {
                this.attachTableData = res
                this.total = res.length
            })
        },
        unitCodeBlur (creditCode) {
            if (creditCode === '') return
            openBiddingRequest.creditcodeAllInfo(creditCode).then(res => {
                if (res.data === null) {
                    this.clientPop('info', '系统外包方库中的分包商不存在，是否新增', () => {
                        this.unitCodeState = false
                        this.unitCodeState2 = false
                        // 库外外包方纳税类别为其他
                        // this.formData.taxpayerType = '其他'
                    })
                } else {
                    this.formData.isOutsideSubcontractors = 1
                    // 基本信息
                    if (res.subcontractor.creditLevel == '3') {
                        this.clientPop(
                            'info',
                            '该单位是不合格分包商，不允许报名，如有疑问请联系招标单位'
                        )
                    } else if (res.subcontractor.creditLevel == '4') {
                        this.clientPop(
                            'info',
                            '该单位在黑名单中，不允许报名，如有疑问请联系招标单位'
                        )
                    } else if (res.subcontractor.creditLevel == '0') {
                        this.clientPop(
                            'info',
                            '该单位信用等级待定，不允许报名，如有疑问请联系招标单位'
                        )
                    } else {
                        this.unitCodeState = true
                        this.unitCodeState2 = false
                        this.formData.unitName = res.subcontractor.orgName
                        this.formData.outsourceType =
                            res.subcontractor.subcontractorTypeValue.split(',')
                        this.formData.outsourceValue =
                            res.subcontractor.subcontractorTypeKey.split(',')
                        this.formData.registerCaptial = res.subcontractor.registerCapital
                        this.formData.legalRepresentative = res.subcontractor.deputy
                        this.formData.registerAddress = res.subcontractor.addressDetail
                        this.formData.newData = false
                        this.formData.taxpayerType = res.subcontractor.taxTypeKey // 纳税类别
                        this.formData.middlePosition = res.subcontractor.aboveTitleQty //中级及以上职称人员数量
                        this.formData.certificateScene = res.subcontractor.certificateQty //持有岗位证书的施工现场管理人员数量
                        this.formData.middleTechnology = res.subcontractor.passedTrainingQty //经考核或培训合格的中级工以上技术工人数量
                        this.formData.socialNum = res.subcontractor.paySocialSecurityQty //正常缴纳社保人数
                        this.formData.certifiedConstructorNum =
                            res.subcontractor.registeredConstructorQty //企业注册建造师数量
                        this.formData.safetyNum = res.subcontractor.safetyCertificateQty //持有安全C证人员数量
                        this.formData.enterpriseBase = res.subcontractor.basicInfo //企业基本情况
                        this.formData.unitName = res.subcontractor.subcontractorName //分包商名称
                        this.formData.fax = res.subcontractor.fax
                        this.formData.telephone = res.subcontractor.contactTel
                        this.formData.zipCode = res.subcontractor.postCode
                        this.formData.email = res.subcontractor.email
                        this.formData.qualificationLevelName = res.qualificationLevelName
                        this.formData.isAbroad = res.subcontractor.isAbroadUnit
                        // 资质信息
                        if (res.qualificationinfoList.length !== 0) {
                            res.qualificationinfoList.map(async (item, index) => {
                                this.$set(this.quaInfoTableData, index, {
                                    billId: '',
                                    certificateGrade: '',
                                    certificateNo: '',
                                    certificateType: '',
                                    changeState: 1,
                                    fileName: '',
                                    filePath: '',
                                    fileSize: 0,
                                    gmtCreate: '',
                                    gmtModified: '',
                                    recordId: '',
                                    upTime: '',
                                    upUser: '',
                                    upUserId: '',
                                    validate: ''
                                })
                                this.quaInfoTableData[index].certificateGrade =
                                    item.qualificationLevelName
                                this.quaInfoTableData[index].certificateNo = item.certNo
                                this.quaInfoTableData[index].certificateType = item.certTypeValue
                                this.quaInfoTableData[index].fileName = item.fileName
                                this.quaInfoTableData[index].fileSize = item.size
                                this.quaInfoTableData[index].upTime = item.gmtCreate
                                this.quaInfoTableData[index].filePath = item.dialogImage
                                // this.quaInfoTableData[index].validate = [item.startDate, item.endDate]
                                this.quaInfoTableData[index].startTime = item.startDate
                                this.quaInfoTableData[index].endTime = item.endDate
                                this.quaInfoTableData[index].recordId = await this.uidBuilder({
                                    num: 1
                                })
                            })
                        }
                        // 历史业绩
                        if (res.performanceList.length !== 0) {
                            res.performanceList.map(async (item, index) => {
                                this.$set(this.enterpriseTableData, index, {
                                    billId: '',
                                    changeState: 1,
                                    contractAmount: 0,
                                    contractName: '',
                                    endTime: '',
                                    fileName: '',
                                    filePath: '',
                                    gmtCreate: '',
                                    gmtModified: '',
                                    personInCharge: '',
                                    projectName: '',
                                    recordId: '',
                                    startTime: '',
                                    witness: '',
                                    witnessPhone: '',
                                    workContent: ''
                                })
                                this.enterpriseTableData[index].contractAmount = item.contractAmount
                                this.enterpriseTableData[index].contractName = item.contractName
                                this.enterpriseTableData[index].endTime = item.endDate
                                this.enterpriseTableData[index].personInCharge = item.projectLeader
                                this.enterpriseTableData[index].projectName = item.projectName
                                this.enterpriseTableData[index].startTime = item.startDate
                                this.enterpriseTableData[index].witness = item.witnessName
                                this.enterpriseTableData[index].witnessPhone = item.witnessTel
                                this.enterpriseTableData[index].workContent = item.workContect
                                this.enterpriseTableData[index].fileName = item.fileName
                                this.enterpriseTableData[index].safetyEvaluation = item.opinion
                                this.enterpriseTableData[index].recordId = await this.uidBuilder({
                                    num: 1
                                })
                            })
                        }
                        // 企业主要管理人
                        //  managerTableData
                        if (res.staffList.length !== 0) {
                            res.staffList.map(async (item, index) => {
                                this.$set(this.managerTableData, index, {
                                    billId: '',
                                    certNo: '',
                                    changeState: 1,
                                    endTime: '',
                                    filePath: '',
                                    gmtModified: '',
                                    idCardNo: '',
                                    name: '',
                                    phone: '',
                                    recordId: '',
                                    startTime: '',
                                    type: ''
                                })
                                this.managerTableData[index].certNo = item.certNo
                                this.managerTableData[index].endTime = item.endDate
                                this.managerTableData[index].gmtModified = item.gmtModified
                                this.managerTableData[index].idCardNo = item.idCard
                                this.managerTableData[index].name = item.staffName
                                this.managerTableData[index].phone = item.tel
                                this.managerTableData[index].startTime = item.beginDate
                                this.managerTableData[index].type = item.personTypeValues
                                this.managerTableData[index].typeName = item.personTypeKey
                                this.managerTableData[index].fileName = item.fileName
                                this.managerTableData[index].filePath = item.filePath
                                this.managerTableData[index].recordId = await this.uidBuilder({
                                    num: 1
                                })
                            })
                        }
                        // 附件信息
                        if (res.attachmentList.length !== 0) {
                            res.attachmentList.map(async (item, index) => {
                                this.$set(this.attachTableData, index, {
                                    type: '',
                                    name: '',
                                    fileName: '',
                                    upTime: '',
                                    size: '',
                                    billId: '',
                                    id: ''
                                })
                                this.attachTableData[index].type = item.fileTypeKey //类型id
                                this.attachTableData[index].size = item.fileSize //大小
                                this.attachTableData[index].name = item.fileName
                                this.attachTableData[index].fileName = item.fileName
                                this.attachTableData[index].upTime = item.gmtCreate
                                this.attachTableData[index].billId = item.billId
                                this.attachTableData[index].id = item.id
                                this.attachTableData[index].recordId = await this.uidBuilder({
                                    num: 1
                                })
                            })
                        }
                    }
                }
            })
        },
        async random19Num () {
            let temp = ''
            await uidBuilder({ num: 1 }).then(res => {
                temp = res[0]
            })
            return temp
        },
        findById () {},
        onSuccess1 (response, file, fileList, recordId) {
            const index = this.enterpriseTableData.findIndex(value => {
                return value.recordId === recordId
            })
            this.$set(this.enterpriseTableData[index], 'ifUpload', true)
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.enterpriseTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess2 (response, file, fileList, recordId) {
            const index = this.quaInfoTableData.findIndex(value => {
                return value.recordId === recordId
            })
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.quaInfoTableData[index], 'fileName', res[0].objectName)
                this.$set(this.quaInfoTableData[index], 'fileSize', res[0].objectSize)
                this.$set(
                    this.quaInfoTableData[index],
                    'upTime',
                    res[0].gmtCreate.slice(0, res[0].gmtCreate.indexOf(' '))
                )
                this.$set(this.quaInfoTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess3 (response, file, fileList, recordId) {
            const index = this.managerTableData.findIndex(value => {
                return value.recordId === recordId
            })
            this.$set(this.managerTableData[index], 'ifUpload', true)
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.managerTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess4 (response, file, fileList, id) {
            const index = this.attachTableData.findIndex(value => {
                return value.id === id
            })
            ossRequest.getObjectByRelationId({ relationId: this.formData.billId }).then(res => {
                const mapRes = {}
                mapRes.fileName = res[0].objectName
                mapRes.filePath = res[0].objectPath
                mapRes.size = res[0].objectSize
                mapRes.type = this.attachTableData[index].type
                mapRes.upLoadTime = res[0].gmtCreate.slice(0, res[0].gmtCreate.indexOf(' '))
                mapRes.recordId = res[0].recordId
                // 用于删除
                this.$set(this.attachTableData, index, mapRes)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onError () {
            this.$message({
                showClose: true,
                type: 'error',
                message: '上传失败'
            })
        },
        async tableDel (key) {
            for (let i = 0; i < this.selection[key].length; i++) {
                const tableData = key + 'TableData'
                const index = this[tableData].findIndex(value2 => {
                    return value2.recordId === value2.recordId
                })
                //后端删除
                if (key === 'enterprise' || key === 'manager') {
                    // 企业主要业绩、企业主要管理人（没有fileName,是我自己加的ifUpload）
                    if (!this[tableData][index].ifUpload) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({
                            recordId: this[tableData][index].recordId
                        })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                        .catch(() => {
                            return
                        })
                    // 资质信息、附件信息
                } else {
                    if (!this[tableData][index].fileName) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({
                            recordId: this[tableData][index].recordId
                        })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                }
            }
        },
        // selectionChange (key, e) {
        //     this.selection[key] = e
        // },
        // eslint-disable-next-line no-unused-vars
        cellClick (row, column, cell, event) {
            if (column.label === '招标编号') {
                this.$router.push({
                    path: './biddingApplicationShow',
                    query: { tenderId: row.billId }
                })
            }
        },
        async getTenderData () {
            await applyRequest.tenderApplyFindById(this.tenderId).then(res => {
                this.formData.projectName = res.tenderName
                this.formData.tenderApplyId = res.billId
                this.formData.tenderApplyNo = res.billNo
                this.formData.applyUnit = res.tenderUser
                this.formData.tenderType = res.tenderClass
                this.formData.enrollTime = this.getNowDate()
                this.formData.projectOverview = res.projectOverview
            })
        },
        getPackage () {
            applyRequest.bidPackageListByBillId(this.tenderId).then(async res => {
                if (res.length === 0) return
                this.packageTableData = res
                // 添加工程概况
                this.packageTableData.forEach(item => {
                    item.projectOverview = this.formData.projectOverview
                })
                // 获取包件名字
                res.forEach(item => {
                    this.formData.packageName += item.name + '，'
                })
                this.formData.packageName = this.formData.packageName.substr(
                    0,
                    this.formData.packageName.length - 1
                )
                // 前端显示的分包商
                // this.pagination.total = res.totalCount || res.length
            })
        },
        onChangeTab (e) {
            const height = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight (arr) {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById(arr[length - 1] + 'Con')) {
                    const lastConHeight = document.getElementById(
                        arr[length - 1] + 'Con'
                    )?.offsetHeight
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        delData () {
            // bidNoticeRequest.batchDelete([this.billId]).then(res => {
            //     this.$message({
            //         showClose: true,
            //         type: 'success',
            //         message: res.message
            //     })
            //     this.$router.push({
            //         path: './biddingApplicationEdit',
            //         query: { billid: this.tenderId, seat: 'reg' }
            //     })
            // })
        },
        showBidding () {
            if (!this.tenderId) return // 前期需求可切换，现在不需要
            this.$notify.closeAll()
            this.$notify({
                title: '查看招标详情',
                dangerouslyUseHTMLString: true,
                message: `正式环境：客户端打开新页面<br>
              测试环境：手动打开新页面<br>
              <el-input cols="35" rows="10">http://localhost:8080/biddingApplicationShow?tenderId=${this.tenderId}</el-input>
              `,
                duration: 0
            })
        },
        getNowDate () {
            // 个位数前补0
            const zeroFill = function (num) {
                if (parseInt(num) < 10) {
                    num = '0' + num
                }
                return num
            }
            let nowtime = new Date()
            nowtime =
                zeroFill(nowtime.getFullYear()) +
                '-' +
                zeroFill(nowtime.getMonth() + 1) +
                '-' +
                zeroFill(nowtime.getDate())
            return nowtime
            // this.$set(this.formData, 'applyTime', nowtime)
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        reset () {
            this.clientPop('info', '确认重置？重置后会将数据全部清空，请谨慎操作！', () => {
                this.formData = {
                    abandondeExplain: '',
                    abandonedReason: '',
                    abandonedTime: '',
                    abandonedUser: '',
                    abandonedUserId: '',
                    applyUnit: '',
                    applyUnitId: '',
                    billId: '',
                    email: '',
                    enrollTime: '',
                    fax: '',
                    fixedTelephone: '',
                    gmtCreate: '',
                    gmtModified: '',
                    legalRepresentative: '',
                    nullifyCreated: '',
                    nullifyCreator: '',
                    nullifyCreatorId: '',
                    nullifyDescription: '',
                    nullifyReason: '',
                    orgId: '',
                    orgName: '',
                    outsourceType: [],
                    packageIds: '',
                    packageName: '',
                    projectName: '',
                    proxyUser: '',
                    registerAddress: '',
                    registerCaptial: null,
                    state: 0,
                    taxpayerType: '',
                    telephone: '',
                    tenderApplyId: '',
                    tenderApplyNo: '',
                    tenderType: 0,
                    unitCode: '',
                    unitName: '',
                    workId: '',
                    zipCode: '',
                    isOutsideSubcontractors: 2
                }
                this.enterpriseTableData = []
                this.quaInfoTableData = []
                this.enterpriseTableData = []
                this.managerTableData = []
                this.attachTableData = []
                this.getTenderData()
                this.getPackage()
            })
        },
        // 外包方类型全选
        handleCheckAllChange (val) {
            this.formData.outsourceType = []
            this.formData.outsourceValue = val
                ? this.typeList.map(item => {
                    return item.kvKey
                })
                : []
            this.isIndeterminate = false
            console.log(1222222, this.formData.outsourceValue)
            // 循环拿到id
            this.typeList.map(item => {
                this.formData.outsourceType.push(item.kvValue)
            })
        },
        //外包方类型选择
        async handleCheckedCitiesChange (value) {
            this.formData.outsourceType = []
            let checkedCount = value.length
            this.checkAll = checkedCount === this.typeList.length
            this.isIndeterminate = checkedCount > 0 && checkedCount < this.typeList.length
            // 通过类型判断是否是小规模纳税人taxTypeKey
            if (value.includes('其他') && checkedCount == 1) {
                this.isShow = false
                this.payTaxesTypeList.map(item => {
                    if (item.kvValue == '1') {
                        this.$set(item, 'disabled', false)
                    }
                })
            } else {
                if (this.formData.isAbroad == 1) {
                    this.isShow = false
                } else {
                    this.isShow = true
                }
                if (this.formData.taxTypeValue == '1') {
                    this.formData.taxTypeValue = '0'
                    this.payTaxesTypeList.map(item => {
                        if (this.formData.taxTypeValue == item.kvValue) {
                            this.formData.taxpayerType = item.kvKey
                        }
                    })
                }
                this.payTaxesTypeList.map(item => {
                    if (item.kvValue == '1') {
                        this.$set(item, 'disabled', true)
                    }
                })
            }
            // 循环拿到id
            this.typeList.map(item => {
                value.map(Valitem => {
                    if (item.kvKey == Valitem) {
                        this.formData.outsourceType.push(item.kvValue)
                    }
                })
            })
            // 自动生成企业主要管理人
            // 如果主要管理人没有数据则自动添加，如果存在数据，则不自动增加
            if (this.managerTableData.length < 1) {
                // 初始化人员类型名字
                let personTypeKeys = [
                    '董事会成员（持股人）',
                    '董事会成员（持股人）',
                    '董事会成员（持股人）',
                    '法人代表',
                    '实际控制人',
                    '总经理',
                    '总工程师',
                    '技术负责人',
                    '质量负责人',
                    '安全负责人',
                    '班组长'
                ]
                let personTypeValues = ['0', '0', '0', '1', '2', '3', '4', '5', '6', '7', '8']
                // 判断数据是否完整并且符合条件
                /**
                 * 1.分包商类型选择“劳务合作、施工分包”中的1个或2个，且不是境外单位的时候
                 * 1)董事会成员（持股人）默认生成3行，至少填写1行
                 * 2)法人代表、实际控制人、总经理、总工程师、技术质量负责人、质量负责人、安全负责人和班组长默认生成1行，至少填写1行；
                 * 2.勾选了境外单位或外包方类型只有其它的时候，则默认生成1行“法人代表”且必填
                 */
                if (
                    (this.formData.outsourceType.includes('8') ||
                        this.formData.outsourceType.includes('9')) &&
                    this.formData.isAbroad == 0
                ) {
                    for (var i in personTypeKeys) {
                        let obj = {
                            billId: '', //	单据ID
                            certNo: '', //证书及编号
                            changeState: 0, //前端操作状态
                            endTime: '', //身份证有效结束日期
                            fileName: '', //身份证附件名称
                            filePath: '', //身份证附件路径
                            gmtModified: '', //上次修改时间
                            idCardNo: '', //身份证号
                            name: '', //姓名
                            phone: '', //	联系电话
                            startTime: '', //身份证有效开始日期
                            type: personTypeValues[i], //	人员类别
                            typeName: personTypeKeys[i], //	人员类别
                            uuid: getUuid(), //本地的uuid区分每条数据
                            recordId: await this.uidBuilder({
                                num: 1
                            })
                        }
                        this.managerTableData.push(obj)
                    }
                } else {
                    let obj = {
                        billId: '', //	单据ID
                        certNo: '', //证书及编号
                        changeState: 0, //前端操作状态
                        endTime: '', //身份证有效结束日期
                        fileName: '', //身份证附件名称
                        filePath: '', //身份证附件路径
                        gmtModified: '', //上次修改时间
                        idCardNo: '', //身份证号
                        name: '', //姓名
                        phone: '', //	联系电话
                        startTime: '', //身份证有效开始日期
                        type: '1', //	人员类别
                        typeName: '法人代表', //	人员类别
                        uuid: getUuid(), //本地的uuid区分每条数据
                        recordId: await this.uidBuilder({
                            num: 1
                        })
                    }
                    this.managerTableData.push(obj)
                }
                this.isLocalDel = true
            }
        },
        // 一般纳税人选择
        radioChange (row) {
            this.payTaxesTypeList.map(item => {
                if (row == item.kvKey) {
                    this.formData.taxTypeValue = item.kvValue
                }
            })
        },
        // 是否为境外单位，判断是否显示企业详情
        isAbroadUnitChange (row) {
            let flag = false
            if (
                this.formData.outsourceValue.includes('其他') &&
                this.formData.outsourceValue.length == 1
            ) {
                flag = true
            } else {
                flag = false
            }
            if (row == 1 || flag) {
                this.isShow = false
            } else {
                this.isShow = true
            }
        },
        //安全生产许可证选择开始时间触发事件
        choiceStart (row, value, index) {
            if (row.certificateType == '安全生产许可证') {
                let tempTime1 = Date.parse(value)
                let newDate = tempTime1 + 31536000000 * 3
                let time = new Date(newDate)
                let year = time.getFullYear() //年
                let month = ('0' + (time.getMonth() + 1)).slice(-2) //月
                let day = ('0' + time.getDate()).slice(-2) //日
                let mydate = year + '-' + month + '-' + day
                this.quaInfoTableData[index].validateEnd = mydate
            }
        },
        // 企业业绩选中的数据
        selectClick1 (selection) {
            this.deleteData1 = selection
        },
        // 资质信息选中的数据
        selectClick2 (selection) {
            this.deleteData2 = selection
        },
        // 主要管理人选中的数据
        selectClick3 (selection) {
            this.deleteData3 = selection
        },
        // 附件选中的数据
        selectClick4 (selection) {
            this.deleteData4 = selection
        },
        // 企业业绩删除
        delete1 () {
            this.deleteData1.map(item => {
                this.enterpriseTableData.map((newitem, index) => {
                    if (item.uuid == newitem.uuid) {
                        this.enterpriseTableData.splice(index, 1)
                    }
                })
            })
        },
        // 资质信息删除
        delete2 () {
            this.deleteData2.map(item => {
                this.quaInfoTableData.map((newitem, index) => {
                    if (item.uuid == newitem.uuid) {
                        this.quaInfoTableData.splice(index, 1)
                    }
                })
            })
        },
        // 主要管理人删除
        delete3 () {
            this.deleteData3.map(item => {
                this.managerTableData.map((newitem, index) => {
                    if (item.uuid == newitem.uuid) {
                        this.managerTableData.splice(index, 1)
                    }
                })
            })
        },
        // 附件删除
        delete4 () {
            this.deleteData4.map(item => {
                this.attachTableData.map((newitem, index) => {
                    if (item.uuid == newitem.uuid) {
                        this.attachTableData.splice(index, 1)
                    }
                })
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.title {
    position: absolute;
    top: 10px;
    right: 30px;
}
::v-deep.require::first-letter {
    color: red !important;
}
.buttons {
    display: flex;
    justify-content: center;
    .el-button {
        padding: 15px 50px;
    }
}
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;

    /* .top {
  .left {
    padding: 20px;
    padding-top: 0px;
  }
} */
}

.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 滚动条 */
.e-form {
    ::-webkit-scrollbar {
        width: 12px;
        height: 15px;
    }

    ::-webkit-scrollbar-track {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: #f6f7f9;
    }

    ::-webkit-scrollbar-thumb {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: rgba(204, 204, 204, 0.8);
    }
    ::-webkit-scrollbar-thumb:window-inactive {
        background: rgba(204, 204, 204, 0.4);
    }
}

// 附件栏
.affix {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .right {
        display: flex;
        align-items: center;
        i {
            margin-left: 10px;
        }
    }
}

.title {
    position: absolute;
    top: 10px;
    right: 30px;
}
.ruleMessage {
    margin-top: 10px;
    margin-bottom: 10px;
    color: red;
}
::v-deep .el-checkbox {
    margin: 0px 15px 5px 0px;
}
// 境外单位
::v-deep .clearPadding .vxe-cell {
    padding: 0;
}
::v-deep .clearPaddingLeft .vxe-cell {
    padding-left: 0px;
}
::v-deep {
    .main-el-switch {
        position: relative;
        .el-switch__core {
            height: 24px;
            border-radius: 12px;
            &:after {
                left: 4px;
                top: 3px;
            }
        }
        &.el-switch {
            &.is-checked {
                .el-switch__core {
                    &:after {
                        margin-left: -20px;
                        left: 100%;
                    }
                }
            }
        }
        &.is-checked {
            .el-switch__label--left {
                opacity: 0;
            }
            .el-switch__label--right {
                opacity: 1;
            }
        }
        .el-switch__label {
            position: absolute;
            top: 0;
        }
        .el-switch__label--left {
            right: 0;
            color: #999;
            z-index: 1;
            margin-right: 8px;
        }
        .el-switch__label--right {
            left: 0;
            color: #fff;
            opacity: 0;
            margin-left: 8px;
        }
    }
}
</style>
